#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>


//./03-fgetc filename
//arg[0] argv[1]
int main(int argc, char const *argv[])
{
    FILE *fp;
    int ch;
    if (argc != 2)//判断参数的个数必须是2个参数
    {
        printf("运行程序时请代入参数: ./fgetc filename\n");
        exit(-1);
    }
    fp = fopen(argv[1],"r");
    if (fp == NULL)
    {
        perror("fopen");
        exit(-1);
    }
    while ((ch=fgetc(fp)) != EOF)
    {
        printf("%c",ch);
    }
    
    fclose(fp);
    
    return 0;
}